<?php

use think\facade\Route;
use app\common\middleware\AuthCheckToken;
use app\common\middleware\AllowCrossDomain;
use app\common\middleware\XcxAuthCheckToken;
// 后台登录相关
Route::group(function(){
    Route::post('login','Login/login');
    Route::get('captcha','Login/verify');
    Route::get('loginout','Login/logout');

    // 后台应用接口
    Route::group('apply', function(){
        Route::post('login','Xcx/login');
        Route::post('getUserInfo','Xcx/getUserInfo');
        Route::get('index','admin.Order/index');
        //订单管理
        Route::group('order', function(){
            Route::post('index','admin.Order/index');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        //拼团订单
        Route::group('groups', function(){
            Route::post('index','admin.Groups/index');

        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        //订单记录
        Route::group('orderrecord', function(){
            Route::post('index','admin.OrderRecord/index');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        //配置参数
        Route::group('settle', function(){
            Route::get('index','admin.Settle/index');
            Route::post('addSettle','admin.Settle/addSettle');
            Route::post('groupSettle','admin.Settle/groupSettle');
            Route::post('groupSettleInfo','admin.Settle/groupSettleInfo');
            Route::post('settleQiweiTags','admin.Settle/settleQiweiTags');
            Route::post('getQiweiTags','admin.Settle/getQiweiTags');
            Route::post('getLingkeTitle','admin.Settle/getLingkeTitle');
            Route::post('addLingkeTitle','admin.Settle/addLingkeTitle');
            Route::post('getSettlePrompt','admin.Settle/getSettlePrompt');
            Route::get('getPromptList','admin.Settle/getPromptList');

        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        //售后订单
        Route::group('refund', function(){
            Route::post('index','admin.Refund/index');
            Route::post('list','admin.Refund/list');
            Route::post('agreeVerify','admin.Refund/agreeVerify');
            Route::post('refuseVerify','admin.Refund/refuseVerify');
            Route::post('agreeVerifyGroups','admin.Refund/agreeVerifyGroups');
            Route::post('refuseVerifyGroups','admin.Refund/refuseVerifyGroups');

        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        //推广链接管理
        Route::group('popuLink', function(){
            //推广链接-列表
            Route::post('getList','admin.PopuLink/getList');
            //推广链接-继承推广链接列表
            Route::post('getInheritList','admin.PopuLink/getInheritList');
            //推广链接-创建推广链接
            Route::post('createPopuLink','admin.PopuLink/createPopuLink');
            //推广链接-查看链接 生成链接和二维码
            Route::post('checkPopuLink','admin.PopuLink/checkPopuLink');
            //推广链接-查询当前推广链接
            Route::post('viewPopuLink','admin.PopuLink/viewPopuLink');
            //推广链接-编辑推广链接
            Route::post('editePopuLink','admin.PopuLink/editePopuLink');
            //推广链接-补货
            Route::post('addGoodsQuantity','admin.PopuLink/addGoodsQuantity');
            //推广链接-修改状态
            Route::post('editeLinkStatus','admin.PopuLink/editeLinkStatus');
            //推广链接-获取商品列表
            Route::post('getGoodsList','admin.PopuLink/getGoodsList');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //客户列表
        Route::group('user', function(){
            Route::post('getUserList','admin.User/getUserList');
            Route::post('getUserInfo','admin.User/getUserInfo');
            Route::post('editPhone','admin.User/editPhone');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //注册链接管理
        Route::group('registerLink', function(){
            //注册链接-列表
            Route::post('getList','admin.RegisterLink/getList');
            //注册链接-创建注册链接
            Route::post('createRegisterLink','admin.RegisterLink/createRegisterLink');
            //注册链接-继承注册链接
            Route::post('inheritRegisterLink','admin.RegisterLink/inheritRegisterLink');
            //注册链接-获取员工列表
            Route::post('getStaffList','admin.RegisterLink/getStaffList');
            //注册链接-获取可以继承的员工列表
            Route::post('getCanInheritStaffList','admin.RegisterLink/getCanInheritStaffList');
            Route::post('is_pingtai','admin.RegisterLink/is_pingtai');
            Route::post('getSelfInfo','admin.RegisterLink/getSelfInfo');
            Route::post('createOneRegisterLink','admin.RegisterLink/createOneRegisterLink');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //推广员审批
        Route::group('examine', function(){
            //推广员审批-列表
            Route::post('getList','admin.ExaminePopu/getList');
            //推广员审批-操作：通过，拒绝
            Route::post('operation','admin.ExaminePopu/operation');
            //推广员审批-操作：继承
            Route::post('inherit','admin.ExaminePopu/inherit');
            //推广员审批-操作：离职
            Route::post('quit','admin.ExaminePopu/quit');
            //操作-离职-通过手机号查找申请通过的推广用户
            Route::post('getUserByPhone','admin.ExaminePopu/getUserByPhone');
            //推广员审批-获取可以继承的员工列表
            Route::post('getCanInheritStaffList','admin.ExaminePopu/getCanInheritStaffList');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //推广员管理
        Route::group('popuUser', function(){
            //推广员管理-列表
            Route::post('getList','admin.PopuUser/getList');
            //推广员管理-操作：继承
            Route::post('inherit','admin.PopuUser/inherit');
            //推广员管理-操作：离职
            Route::post('quit','admin.PopuUser/quit');
            //推广员管理-获取可以继承的员工列表
            Route::post('getCanInheritStaffList','admin.PopuUser/getCanInheritStaffList');
            //获取离职员工
            Route::post('getResignList','admin.PopuUser/getResignList');
            //获取继承人员列表
            Route::post('getInheritList','admin.PopuUser/getInheritList');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);


        //提现审批列表
        Route::group('userPay', function(){
            Route::post('getUserPayList','admin.UserPay/getUserPayList');
            Route::post('refuseApply','admin.UserPay/refuseApply');
            Route::post('passApply','admin.UserPay/passApply');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //商品管理
        Route::group('goods', function(){
            //商品管理-获取商品列表
            Route::post('getlist','admin.Goods/getList');
            //商品管理-创建商品
            Route::post('addGoods','admin.Goods/addGoods');
            //商品管理-调价提交
            Route::post('changePrice','admin.Goods/changePrice');
            //商品管理-获取推广链接数
            Route::post('getPopulinks','admin.Goods/getPopulinks');
            //商品管理-商品详情
            Route::post('goodsDetail','admin.Goods/goodsDetail');
            //商品管理-商品编辑
            Route::post('goodsEdit','admin.Goods/goodsEdit');
            //商品管理-商品禁用
            Route::post('goodsDisable','admin.Goods/goodsDisable');
            //商品管理-商品删除
            Route::post('goodsDelete','admin.Goods/goodsDelete');
            //商品管理-调价记录
            Route::post('changePriceLog','admin.Goods/changePriceLog');
            //推广看板-获取记录
            Route::post('popuBoard/getList','admin.Goods/getList');
            //推广看板-提现
            Route::post('popuBoard/withDraw','admin.Goods/withDraw');
        });

        //团购商品管理
        Route::group('goodsTuan', function(){
            //商品管理-获取商品列表
            Route::post('getlist','admin.GoodsTuan/getList');
            //商品管理-创建商品
            Route::post('addGoods','admin.GoodsTuan/addGoods');
            //商品管理-调价提交
            Route::post('changePrice','admin.GoodsTuan/changePrice');
            //商品管理-获取推广链接数
            Route::post('getPopulinks','admin.GoodsTuan/getPopulinks');
            //商品管理-商品详情
            Route::post('goodsDetail','admin.GoodsTuan/goodsDetail');
            //商品管理-商品编辑
            Route::post('goodsEdit','admin.GoodsTuan/goodsEdit');
            //商品管理-商品禁用
            Route::post('goodsDisable','admin.GoodsTuan/goodsDisable');
            //商品管理-商品删除
            Route::post('goodsDelete','admin.GoodsTuan/goodsDelete');
            //商品管理-调价记录
            Route::post('changePriceLog','admin.GoodsTuan/changePriceLog');
            //推广看板-获取记录
            Route::post('popuBoard/getList','admin.GoodsTuan/getList');
            //推广看板-提现
            Route::post('popuBoard/withDraw','admin.GoodsTuan/withDraw');
        });

        //下单之后生成的account  后台查询展示接口
        Route::group('kanke_list', function(){
            //商品管理-获取商品列表
            Route::post('getlist','admin.Kanke/getlist');
        });

        //商品调价走的定时任务
        Route::group('goods_task', function(){
            //商品管理-获取商品列表
            Route::post('change_price','admin.Goods/change_price_task');
        });
        //调价记录
        Route::group('tiaojia_record', function(){
            //商品管理-获取商品列表
            Route::post('getlist','admin.Tiaojiarecord/getlist');
        });

        //推广看板
        Route::group('popuBoard', function(){
            //推广看板-获取记录
            Route::post('getList','admin.PopuBoard/getList');
            //推广看板-提现
            Route::post('withDraw','admin.PopuBoard/withDraw');
        });

        //海报管理
        Route::group('posters', function(){
            //推广海报列表
            Route::post('getPopuList','admin.Poster/getPopuList');
            //团购海报列表
            Route::post('getGroupList','admin.Poster/getGroupList');
            //制作海报
            Route::post('createdPoster','admin.Poster/createdPoster');
            //通过id获取海报信息
            Route::post('getPosterInfo','admin.Poster/getPosterInfo');
            //编辑海报
            Route::post('editePoster','admin.Poster/editePoster');
            //删除海报
            Route::post('delPoster','admin.Poster/delPoster');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //海报模板管理
        Route::group('postersTemplate', function(){
            //海报模板列表
            Route::post('getList','admin.PosterTemplate/getList');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //关于我们管理
        Route::group('about', function(){
            //关于我们列表
            Route::post('getList','admin.Aboutus/getList');
            //创建我们列表
            Route::post('created','admin.Aboutus/created');
            //修改我们列表
            Route::post('edited','admin.Aboutus/edited');
            //关于我们详细信息
            Route::post('getInfo','admin.Aboutus/getInfo');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //审批记录
        Route::group('examineRecord', function(){
            Route::post('getList','admin.ExamineLog/getList');
            Route::post('getUserPayRecord','admin.UserPay/getUserPayRecord');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        //数据看板
        Route::group('popuPanel', function(){
            Route::post('getPopuPanel','admin.PopuPanel/getPopuPanel');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

        //拼团链接管理
        Route::group('groupLink', function(){
            Route::post('getList','admin.GroupLink/getList');
            Route::post('createGroupLink','admin.GroupLink/createGroupLink');
            Route::post('checkGroupLink','admin.GroupLink/checkGroupLink');
            Route::post('viewGroupLink','admin.GroupLink/viewGroupLink');
            Route::post('editeGroupLink','admin.GroupLink/editeGroupLink');
            Route::post('editeLinkStatus','admin.GroupLink/editeLinkStatus');
            Route::post('getGoodsList','admin.GroupLink/getGoodsList');
            Route::post('getLoginInfo','admin.GroupLink/getLoginInfo');
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        //拼团团队信息记录
        Route::group('groupsTeam', function(){
            Route::post('index','admin.GroupsTeam/index');
            Route::post('list','admin.GroupsTeam/list');
    
        })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);
        
        
    })->middleware([AllowCrossDomain::class, AuthCheckToken::class]);

})->middleware([AllowCrossDomain::class]);

// 小程序接口
Route::group('xcx', function(){
    // 小程序登录接口
    Route::post('actionLogin','xcx.Login/actionLogin');
    Route::post('login','xcx.Login/Login');
    Route::post('phone','xcx.Login/phone');
    Route::post('pay/notify','xcx.Payment/notify');  //微信支付回调

    Route::post('insertData','xcx.Things/insertData');
    Route::post('getFood','xcx.Things/getFood');
    Route::post('getLocation','xcx.Things/getLocation');
    Route::post('getStatistics','xcx.Statistics/getStatistics');

    Route::post('getRound','xcx.Things/getRound');
    
    /**
     * 需要用户登录接口
     */
    Route::group('logins', function(){
        //分销商品详情
        Route::post('getGoodsList','xcx.Goods/getGoodsList');
        Route::post('getGoodsDetail','xcx.Goods/getGoodsDetail');
        //拼团商品详情
        Route::post('getGoodsListSeller','xcx.Seller/getGoodsList');
        Route::post('getGoodsListSellerTuan','xcx.Seller/getGoodsListTuan');
        Route::post('getGoodsDetailSeller','xcx.Seller/getGoodsDetail');
        Route::post('sellerGoodsData','xcx.Seller/sellerGoodsData');
        Route::post('sellerGoodsDataTotal','xcx.Seller/sellerGoodsDataTotal');
        Route::post('sellerGoodsSelect','xcx.Seller/sellerGoodsSelect');
        
        //申请推广员
        Route::post('applyPromoter','xcx.Promoter/applyPromoter');
        Route::post('getPromoterInfoCode','xcx.Promoter/getPromoterInfoCode');
        Route::post('getPromoterInfo','xcx.Promoter/getPromoterInfo');
        Route::post('getPromoterQrcode','xcx.Promoter/getPromoterQrcode');

        // 订单接口
        Route::post('receiveUserOrder','xcx.Order/receiveUserOrder');
        Route::post('getUserOrderList','xcx.Order/getUserOrderList');
        Route::post('cancelOrder','xcx.Order/cancelOrder');
        Route::post('refundOrder','xcx.Order/refundOrder');
        Route::post('confirmOrder','xcx.Order/confirmOrder');
        Route::post('cancelRefund','xcx.Order/cancelRefund');

        //用户收货地址
        Route::post('addUserAddress','xcx.Address/addUserAddress');
        Route::post('editUserAddress','xcx.Address/editUserAddress');
        Route::post('deleteUserAddress','xcx.Address/deleteUserAddress');
        Route::post('getUserAddressList','xcx.Address/getUserAddressList');
        Route::post('SettingsAddress','xcx.Address/SettingsAddress');
        Route::post('getUserAddressPhone','xcx.Address/getUserAddressPhone');
        
        //获取用户信息
        Route::post('getUserInfo','xcx.Login/getUserInfo');
        Route::post('getUserInfo2','xcx.Login/getUserInfo2');


        //申请提现
        Route::post('userPayApply','xcx.UserPayApply/userPayApply');
        //提现列表
        Route::post('userPayInfo','xcx.UserPayApply/userPayInfo');
        //我的客户列表
        Route::post('getUserList','xcx.User/getUserList');
        //我的客户详情
        Route::post('userInfo','xcx.User/userInfo');

        //推广数据
        Route::post('getAllPopuData','xcx.PopuData/getAllPopuData');
        Route::post('getPopuDataByDate','xcx.PopuData/getPopuDataByDate');
        Route::post('insertPopuDataByDate','xcx.PopuData/insertPopuDataByDate');

        //我的
        Route::post('getMyPopuData','xcx.PopuData/getMyPopuData');
        Route::post('getMyPopuInfo','xcx.PopuData/getMyPopuInfo');
        Route::post('setRemark','xcx.PopuData/setRemark');
        Route::post('getMyPopuStatistics','xcx.PopuData/getMyPopuStatistics');
        Route::post('getTransactionData','xcx.PopuData/getTransactionData');
        Route::post('setClickPopuLink','xcx.PopuData/setClickPopuLink');
        Route::post('getOrderCount','xcx.User/getOrderCount');


        //推广素材
        Route::post('getPosters','xcx.PopuData/getPosters');
        //团购推广素材
        Route::post('getGroupPosters','xcx.PopuData/getGroupPosters');
        
        //获取拼团链接
        Route::post('getMyGroup','xcx.Groups/getMyGroup');
        Route::post('getGroupInfo','xcx.Groups/getGroupInfo');
        Route::post('getGroupSharePoster','xcx.Groups/getGroupSharePoster');
        Route::post('recordGroupsLog','xcx.Groups/recordGroupsLog');
        Route::post('getMySuceesGroup','xcx.Groups/getMySuceesGroup');
        Route::post('commonSharePoster','xcx.Groups/commonSharePoster');
        Route::post('getLimitedGroupOrder','xcx.Groups/getLimitedGroupOrder');


        //微信支付
        Route::post('orderInfo','xcx.Payment/orderInfo');
        //拼团订单
        Route::post('addGroupsOrder','xcx.Groups/addGroupsOrder');
        Route::post('getGroupsOrderList','xcx.Groups/getGroupsOrderList');
        Route::post('verifyGroups','xcx.Groups/verifyGroups');
        Route::post('getGroupOrder','xcx.Groups/getGroupOrder');
        Route::post('getGroupOrderGoods','xcx.Groups/getGroupOrderGoods');

    })->middleware([AllowCrossDomain::class, XcxAuthCheckToken::class]);

    // 用户其他信息
    Route::group('user', function(){
        Route::post('setSellGroups','xcx.Login/setSellGroups');
    })->middleware([AllowCrossDomain::class, XcxAuthCheckToken::class]);
});   
//})->middleware([AllowCrossDomain::class]);

// 小程序接口
Route::group('xcx_v1', function(){
    // 小程序登录接口
    Route::post('actionLogin','xcx.Login/actionLogin');
    Route::post('login','xcx.Login/Login');
    Route::post('getGoodsList','xcx_v1.Goods/getGoodsList');
    Route::post('getGoodsDetail','xcx_v1.Goods/getGoodsDetail');
    Route::post('test','xcx_v1.Test/test');
    Route::post('change_price','admin.Goods/change_price_task');


    /**
     * 需要用户登录接口
     */
    Route::group('logins', function(){
        // 订单接口
        Route::post('confirmOrder','xcx.Order/confirmOrder');
        Route::post('cancelRefund','xcx.Order/cancelRefund');

    })->middleware([AllowCrossDomain::class, XcxAuthCheckToken::class]);
})->middleware([AllowCrossDomain::class]);


